package com.wing.cms.dao;

import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.wing.common.CommonSpringJDBC;
import com.wing.common.util.PageBean;
import com.wing.cms.domain.Artgroup;

@Repository
public class ArtgroupDao extends CommonSpringJDBC<Artgroup, String> {

	public PageBean findPageList(int currentPage, int pageSize, Object... args) {
		String where = " pid='" + args[0] + "' and site_id='" + args[1] + "' ";
		String sql1 = " SELECT * FROM cms_artgroup where " + where
				+ " ORDER BY id ASC " + " LIMIT " + (currentPage - 1)
				* pageSize + "," + pageSize;
		String sql2 = "select count(id) from  cms_artgroup  where" + where;
		String[] sqlArray = { sql1, sql2 };
		return super.findPageList(sqlArray, currentPage, pageSize);
	}

	public List<Map<String, Object>> findChildByID(String parentid,
			String siteId) {
		String sql = "select t.* from cms_artgroup t where t.pid=? and t.site_id=? order by order_num";
		Object[] objs = { parentid, siteId };
		return super.getSimpleJdbcTemplate().queryForList(sql, objs);
	}

	public List<Map<String, Object>> findChildByID(String parentid) {
		String sql = "select t.* from cms_artgroup t where t.pid=? order by order_num";
		Object[] objs = { parentid };
		return super.getSimpleJdbcTemplate().queryForList(sql, objs);
	}


}
